home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Financial / Emerald1.0 / Source / AnalysisUSObject.m < prev    next >
Encoding:
Text File  |  1996-03-03  |  18.8 KB  |  533 lines

  1.  
  2. #import "AnalysisUSObject.h"
  3.  
  4. @implementation AnalysisUSObject
  5.  
  6. // Gobal Variables
  7.  
  8.     char buffer[800];     // Text buffer
  9.  
  10. // AWAKEFROMNIB
  11. // This is one of the last methods executed after the nib file is loaded.
  12. // This is the BEST way I know how to initialize an object and jump into
  13. // a method after the nib file was loaded, because you are all the methods
  14. // and variables needed can be used. (Unlike init which is not compeletly
  15. // ready when that message is sent
  16. - awakeFromNib
  17. {
  18.  
  19.     [AnalysisWindow makeKeyAndOrderFront:NULL];
  20.     [StockPrice selectText:self];
  21.  
  22.         return self;
  23. }
  24.  
  25. - Calc:sender
  26. {
  27.  
  28.     //Assign Misc Variables
  29.         char dummyString[20];
  30.         int WhichOne;
  31.     float stockprice;
  32.         float numberofshares;
  33.         float totalstockprice;
  34.         float totalcommission;
  35.     float totalcommissioncharges;
  36.         float total;
  37.     float netamountpershare;
  38.     float totalcommpershare;
  39.     float netprofitlost;
  40.     float netprofitlostpershare;
  41.     float stockprice2;
  42.         float numberofshares2;
  43.         float totalstockprice2;
  44.         float totalcommission2;
  45.         float total2;
  46.     float netamountpershare2;
  47.     float breakeven;
  48.     float neededvalue;
  49.     float neededvalue2;
  50.         float buycommission;
  51.         float netamount;
  52.  
  53.     //Assign Values for Buy section
  54.     stockprice = [StockPrice floatValue];
  55.     numberofshares = [NumberOfShares floatValue];
  56.         [NumberOfShares2 setFloatValue:numberofshares];
  57.  
  58.     //Assign Values for Sell section
  59.     stockprice2 = [StockPrice2 floatValue];
  60.     numberofshares2 = [NumberOfShares2 floatValue];
  61.  
  62.  
  63.     // Take the value in Stock Price * Number of Shares and display
  64.     // the result in the Total Stock Price textfield
  65.     
  66.     // For Buy section
  67.     totalstockprice = [StockPrice floatValue] * [NumberOfShares floatValue];
  68.     sprintf(dummyString, "%.2f", totalstockprice); 
  69.     [TotalStockPrice setStringValue:dummyString];// Display result
  70.  
  71.     // For Sell Section
  72.     totalstockprice2 = [StockPrice2 floatValue] * [NumberOfShares2 floatValue];
  73.     sprintf(dummyString, "%.2f", totalstockprice2); 
  74.     [TotalStockPrice2 setStringValue:dummyString];// Display result
  75.     //[TotalStockPrice2 setFloatValue:totalstockprice2]; // Display result
  76.     //[TotalStockPrice2 display];
  77.  
  78.     // COMMISSION RATE SECTION **************************
  79.  
  80.  
  81.     // Figure out the commission rate and then do the calculations
  82.  
  83.     // Checks if the stock price is below Stock1 if yes then
  84.     // calculates the commission using Comm1
  85.  
  86.     // For Sell Section
  87.     if ([StockPrice floatValue] <= [Stock2 floatValue]) totalcommission = (([StockPrice floatValue] * [NumberOfShares floatValue]) * ([Comm1 floatValue] / 100));
  88.  
  89.     // For Buy Section
  90.     if ([StockPrice2 floatValue] <= [Stock2 floatValue]) totalcommission2 = (([StockPrice2 floatValue] * [NumberOfShares2 floatValue]) * ([Comm1 floatValue] / 100));
  91.  
  92.     // Checks if the stock price is >=Stock3 and <= Stock4 if yes then
  93.     // calculates the commission by adding Comm2 and multiplying
  94.     // Comm3 by the number of shares
  95.  
  96.     // For Buy section
  97.     if ([StockPrice floatValue] >= [Stock3 floatValue] && [StockPrice floatValue] <= [Stock4 floatValue]) totalcommission = ([Comm2 floatValue] + ([NumberOfShares floatValue] * [Comm3 floatValue]));
  98.  
  99.     // For Sell section
  100.     if ([StockPrice2 floatValue] >= [Stock3 floatValue] && [StockPrice2 floatValue] <= [Stock4 floatValue]) totalcommission2 = ([Comm2 floatValue] + ([NumberOfShares2 floatValue] * [Comm3 floatValue]));
  101.  
  102.     // Checks if the stock price is >=Stock5 and <= Stock6 if yes then
  103.     // calculates the commission by adding Comm4 and multiplying
  104.     // Comm5 by the number of shares
  105.  
  106.     // For Buy section
  107.     if ([StockPrice floatValue] >= [Stock5 floatValue] && [StockPrice floatValue] <= [Stock6 floatValue]) totalcommission = ([Comm4 floatValue] + ([NumberOfShares floatValue] * [Comm5 floatValue]));
  108.  
  109.     // For Sell section
  110.     if ([StockPrice2 floatValue] >= [Stock5 floatValue] && [StockPrice2 floatValue] <= [Stock6 floatValue]) totalcommission2 = ([Comm4 floatValue] + ([NumberOfShares2 floatValue] * [Comm5 floatValue]));
  111.  
  112.     // Checks if the stock price is >=Stock7 and <= Stock8 if yes then
  113.     // calculates the commission by adding Comm6 and multiplying
  114.     // Comm7 by the number of shares
  115.  
  116.     // For Buy section
  117.     if ([StockPrice floatValue] >= [Stock7 floatValue] && [StockPrice floatValue] <= [Stock8 floatValue]) totalcommission = ([Comm6 floatValue] + ([NumberOfShares floatValue] * [Comm7 floatValue]));
  118.  
  119.     // For Sell section
  120. if ([StockPrice2 floatValue] >= [Stock7 floatValue] && [StockPrice2 floatValue] <= [Stock8 floatValue]) totalcommission2 = ([Comm6 floatValue] + ([NumberOfShares2 floatValue] * [Comm7 floatValue]));
  121.  
  122.     // Checks if the stock price is >=Stock9 and <= Stock10 if yes then
  123.     // calculates the commission by adding Comm8 and multiplying
  124.     // Comm9 by the number of shares
  125.  
  126.     // For Buy section
  127.     if ([StockPrice floatValue] >= [Stock9 floatValue] && [StockPrice floatValue] <= [Stock10 floatValue]) totalcommission = ([Comm8 floatValue] + ([NumberOfShares floatValue] * [Comm9 floatValue]));
  128.  
  129.     // For Sell section
  130. if ([StockPrice2 floatValue] >= [Stock9 floatValue] && [StockPrice2 floatValue] <= [Stock10 floatValue]) totalcommission2 = ([Comm8 floatValue] + ([NumberOfShares2 floatValue] * [Comm9 floatValue]));
  131.  
  132.     // Checks if the stock price is >=Stock11 and <= Stock12 if yes then
  133.     // calculates the commission by adding Comm10 and multiplying
  134.     // Comm11 by the number of shares
  135.  
  136.     // For Buy section
  137.     if ([StockPrice floatValue] >= [Stock11 floatValue] && [StockPrice floatValue] <= [Stock12 floatValue]) totalcommission = ([Comm10 floatValue] + ([NumberOfShares floatValue] * [Comm11 floatValue]));
  138.  
  139.     // For Sell section
  140.     if ([StockPrice2 floatValue] >= [Stock11 floatValue] && [StockPrice2 floatValue] <= [Stock12 floatValue]) totalcommission2 = ([Comm10 floatValue] + ([NumberOfShares2 floatValue] * [Comm11 floatValue]));
  141.  
  142.     // Checks if the stock price is >=Stock13 and <= Stock14 if yes then
  143.     // calculates the commission by adding Comm12 and multiplying
  144.     // Comm13 by the number of shares
  145.  
  146.     // For Buy section
  147.     if ([StockPrice floatValue] >= [Stock13 floatValue] && [StockPrice floatValue] <= [Stock14 floatValue]) totalcommission = ([Comm12 floatValue] + ([NumberOfShares floatValue] * [Comm13 floatValue]));
  148.  
  149.     // For Sell section
  150.     if ([StockPrice2 floatValue] >= [Stock13 floatValue] && [StockPrice2 floatValue] <= [Stock14 floatValue]) totalcommission2 = ([Comm12 floatValue] + ([NumberOfShares2 floatValue] * [Comm13 floatValue]));
  151.  
  152. // Checks if the stock price is >=Stock15 if yes then
  153. // calculates the commission by adding Comm14 and multiplying
  154. // Comm15 by the number of shares
  155.     
  156.     // For Buy section
  157.     if ([StockPrice floatValue] >= [Stock15 floatValue]) totalcommission = ([Comm14 floatValue] + ([NumberOfShares floatValue] * [Comm15 floatValue]));
  158.  
  159.     // For Sell section
  160.     if ([StockPrice2 floatValue] >= [Stock15 floatValue]) totalcommission2 = ([Comm14 floatValue] + ([NumberOfShares2 floatValue] * [Comm15 floatValue]));
  161.  
  162.     
  163.  
  164.     // DISPLAY SECTION **************************
  165.  
  166.     // Assign variables
  167.     totalstockprice = [TotalStockPrice floatValue];
  168.     totalstockprice2 = [TotalStockPrice2 floatValue];
  169.  
  170.     // Transactions with principal values less than Principal Value 
  171.         //will be charged a flat fee of FlatFee
  172.         if ([TotalStockPrice floatValue] <= [PrincipalValue floatValue]) totalcommission = [FlatFee floatValue];
  173.         if ([TotalStockPrice2 floatValue] <= [PrincipalValue floatValue]) totalcommission2 = [FlatFee floatValue];
  174.  
  175.  
  176.     // Assigns the value of the currently selected radio button
  177.      // using tag as a reference and calculate Net Amount
  178.        WhichOne = [RadioButton selectedTag]; 
  179.     if (WhichOne == 2)  totalcommission = totalcommission -(totalcommission * ([TeleMaxInput floatValue] / 100));
  180.     if (WhichOne == 2)  totalcommission2 = totalcommission2 -(totalcommission2 * ([TeleMaxInput floatValue] / 100));
  181.  
  182.     total = totalstockprice + totalcommission;
  183.     total2 = totalstockprice2 - totalcommission2;
  184.  
  185.     
  186.     // Display Total Commission 
  187.     // Convert float to a string
  188.     sprintf(dummyString, "%.2f", totalcommission); 
  189.     [TotalCommission setStringValue:dummyString];// Display result
  190.     sprintf(dummyString, "%.2f", totalcommission2); 
  191.     [TotalCommission2 setStringValue:dummyString];// Display result
  192.  
  193.     // Display Net Amount
  194.     sprintf(dummyString, "%.2f", total); // Convert float to a string
  195.     [Total setStringValue:dummyString];// Display result
  196.     sprintf(dummyString, "%.2f", total2); // Convert float to a string
  197.     [Total2 setStringValue:dummyString];// Display result
  198.  
  199.     // Calculate Net Amount Per Share
  200.     // Number of Shares / Net Amount = Net Amount per Share
  201.     netamountpershare =  [Total floatValue] / [NumberOfShares floatValue];
  202.     netamountpershare2 =  [Total2 floatValue] / [NumberOfShares2 floatValue];
  203.     // Display Net Amount per Share
  204.     sprintf(dummyString, "%.2f", netamountpershare);
  205.     [NetAmountPerShare setStringValue:dummyString];// Display result
  206.     [NetAmountPerShare display];
  207.     sprintf(dummyString, "%.2f", netamountpershare2);
  208.     [NetAmountPerShare2 setStringValue:dummyString];// Display result
  209.     [NetAmountPerShare2 display];
  210.  
  211. // ANALYSIS ***************************
  212.  
  213.     // Calc and Display Result for Share Price Difference
  214.     [SharePriceDifference setFloatValue:[StockPrice2 floatValue]-[StockPrice floatValue]];
  215.     
  216.     // If Negative value text is RED
  217.     if ([SharePriceDifference floatValue] < 0) [SharePriceDifference setTextColor:NX_COLORRED];
  218.     
  219.     // If Positive value text is BLACK
  220.     if ([SharePriceDifference floatValue] >= 0) [SharePriceDifference setTextColor:NX_COLORBLACK];
  221.  
  222.     // Calc and Display Result for Total Commission Charges
  223.     totalcommissioncharges = [TotalCommission floatValue] + [TotalCommission2 floatValue];
  224.     sprintf(dummyString, "%.2f", totalcommissioncharges);
  225.     [TotalCommissionCharges setStringValue:dummyString];// Display result
  226.     [TotalCommissionCharges display];
  227.  
  228.     // Calc and Display Total Commission Charge per Share
  229.     totalcommpershare = [TotalCommissionCharges floatValue] / [NumberOfShares floatValue];
  230.     sprintf(dummyString, "%.5f", totalcommpershare);
  231.     [TotalCommPerShare setStringValue:dummyString];// Display result
  232.     [TotalCommPerShare display];
  233.  
  234.     // Calc and Display Net Profit or Lost
  235.     netprofitlost = [Total2 floatValue] - [Total floatValue];
  236.  
  237.     // If Negative value text is RED
  238.     if (netprofitlost < 0) [NetProfitLost setTextColor:NX_COLORRED];
  239.  
  240.     // If Positive value text is BLACK
  241.     if (netprofitlost >= 0) [NetProfitLost setTextColor:NX_COLORBLACK];
  242. sprintf(dummyString, "%.2f", netprofitlost);
  243.     [NetProfitLost setStringValue:dummyString];// Display result
  244.     [NetProfitLost display];
  245.  
  246.     
  247.     // Calc and Display Net Profit or Lost per Share
  248.     netprofitlostpershare = [NetProfitLost floatValue] / [NumberOfShares floatValue];
  249.  
  250.     // If Negative value text is RED    
  251.     if (netprofitlostpershare < 0) [NetProfitLostPerShare setTextColor:NX_COLORRED];
  252.  
  253.     // If Positive value text is BLACK
  254.     if (netprofitlostpershare >= 0) [NetProfitLostPerShare setTextColor:NX_COLORBLACK];
  255. sprintf(dummyString, "%.5f", netprofitlostpershare);
  256. [NetProfitLostPerShare setStringValue:dummyString];// Display result
  257. [NetProfitLostPerShare display];
  258.  
  259.  
  260.     // BREAKEVEN ************************
  261.     // Breakeven is simply getting the "Buy" Net Amount per Share
  262.         // Equal to the "Sell" Net Amount per Share.
  263.     //
  264.     // This is done by increasing the value of the stock price by
  265.     // 0.05 then multiply by the number of shares, less the commission 
  266.     // charge then dividing by number of shares.
  267.     // If this value is equal to "Buy" Net Amount per Share
  268.     // Then your stock price is the correct one for breakeven.
  269.     
  270.  
  271.         buycommission = [TotalCommission floatValue];
  272.     numberofshares = [NumberOfShares floatValue];
  273.     netamount = [Total floatValue];    
  274.     breakeven = [StockPrice floatValue];
  275.  
  276.     // Start of the BREAKEVEN GOTO LOOP 
  277.     BREAKEVENstart:breakeven = breakeven + 0.01;
  278.  
  279.     // COMMISSION RATE SECTION  FOR BREAKEVEN **********************
  280.  
  281.     // Figure out the commission rate and then do the calculations
  282.  
  283.     // Checks if the stock price is below Stock1 if yes then
  284.     // calculates the commission using Comm1
  285.  
  286.     // For Sell Section
  287.     if (breakeven <= [Stock2 floatValue]) totalcommission = ((breakeven * [NumberOfShares floatValue]) * ([Comm1 floatValue] / 100));
  288.  
  289.     // Checks if the stock price is >=Stock3 and <= Stock4 if yes then
  290.     // calculates the commission by adding Comm2 and multiplying
  291.     // Comm3 by the number of shares
  292.  
  293.     // For Sell section
  294.     if (breakeven >= [Stock3 floatValue] && breakeven <= [Stock4 floatValue]) totalcommission = ([Comm2 floatValue] + ([NumberOfShares floatValue] * [Comm3 floatValue]));
  295.  
  296.     // Checks if the stock price is >=Stock5 and <= Stock6 if yes then
  297.     // calculates the commission by adding Comm4 and multiplying
  298.     // Comm5 by the number of shares
  299.  
  300.     // For Sell section
  301.     if (breakeven >= [Stock5 floatValue] && breakeven <= [Stock6 floatValue]) totalcommission = ([Comm4 floatValue] + ([NumberOfShares floatValue] * [Comm5 floatValue]));
  302.  
  303.     // Checks if the stock price is >=Stock7 and <= Stock8 if yes then
  304.     // calculates the commission by adding Comm6 and multiplying
  305.     // Comm7 by the number of shares
  306.  
  307.     // For Sell section
  308.     if (breakeven >= [Stock7 floatValue] && breakeven <= [Stock8 floatValue]) totalcommission = ([Comm6 floatValue] + ([NumberOfShares floatValue] * [Comm7 floatValue]));
  309.  
  310.     // Checks if the stock price is >=Stock9 and <= Stock10 if yes then
  311.     // calculates the commission by adding Comm8 and multiplying
  312.     // Comm9 by the number of shares
  313.  
  314.     // For Sell section
  315.     if (breakeven >= [Stock9 floatValue] && breakeven <= [Stock10 floatValue]) totalcommission = ([Comm8 floatValue] + ([NumberOfShares floatValue] * [Comm9 floatValue]));
  316.  
  317.     // Checks if the stock price is >=Stock11 and <= Stock12 if yes then
  318.     // calculates the commission by adding Comm10 and multiplying
  319.     // Comm11 by the number of shares
  320.  
  321.     // For Sell section
  322.     if (breakeven >= [Stock11 floatValue] && breakeven <= [Stock12 floatValue]) totalcommission = ([Comm10 floatValue] + ([NumberOfShares floatValue] * [Comm11 floatValue]));
  323.  
  324.     // Checks if the stock price is >=Stock13 and <= Stock14 if yes then
  325.     // calculates the commission by adding Comm12 and multiplying
  326.     // Comm13 by the number of shares
  327.  
  328.     // For Sell section
  329.     if (breakeven >= [Stock13 floatValue] && breakeven <= [Stock14 floatValue]) totalcommission = ([Comm12 floatValue] + ([NumberOfShares floatValue] * [Comm13 floatValue]));
  330.  
  331. // Checks if the stock price is >=Stock15 if yes then
  332. // calculates the commission by adding Comm14 and multiplying
  333. // Comm15 by the number of shares
  334.  
  335.     // For Sell section
  336.     if (breakeven >= [Stock15 floatValue]) totalcommission = ([Comm14 floatValue] + ([NumberOfShares floatValue] * [Comm15 floatValue]));
  337.  
  338.  
  339.     // Transactions with principal values less than Principal Value 
  340.         //will be charged a flat fee of FlatFee
  341.         if ((breakeven*[NumberOfShares floatValue]) < [PrincipalValue floatValue]) totalcommission = [FlatFee floatValue];
  342.  
  343.     // The target value your trying to find.    
  344.     neededvalue = [NetAmountPerShare floatValue];
  345.  
  346.     // Calculating the Net Amount per Share based on the breakeven
  347.     // value and the commission charges for that value divided
  348.     // by the number of shares
  349.     neededvalue2 = ((breakeven * numberofshares) - totalcommission) / numberofshares; 
  350.  
  351.     // Checking to see if Net Amount per Share for breakeven
  352.     // is smaller then the target value Net Amount per Share
  353.     // in the Buy box IF SO then increase the breakeven value
  354.     if (neededvalue2 < neededvalue) goto BREAKEVENstart;
  355.     
  356.     // Display breakeven value in the BREAKEVEN, Analysis box
  357.     sprintf(dummyString, "%.2f", breakeven);
  358.     [BreakEven setStringValue:dummyString];// Display result
  359.     [BreakEven display];
  360.  
  361.  
  362.     [StockPrice selectText:self];
  363.  
  364.  
  365.     return self;
  366. }
  367.  
  368.  
  369.  
  370. - DirectTrading:sender
  371. {
  372.     return self;
  373. }
  374.  
  375. - PrintCommSchedule:sender
  376. {
  377.  
  378.     [CommissionWindow printPSCode:self];
  379.  
  380.     return self;
  381. }
  382.  
  383. - PrintAll:sender
  384. {
  385.  
  386.  
  387.     // Clears the MyScrollView scrollView
  388.     [[MyScrollView docView] setText:""];
  389.  
  390.     [ReportWindow makeKeyAndOrderFront:NULL];
  391.  
  392.     // Header
  393.  
  394.     sprintf(buffer,"\n                *** Emerald ***\n");
  395.     [self appendText:sender];
  396.  
  397.     sprintf(buffer,"The NEXTSTEP/OPENSTEP Financial Tool.\n");
  398.     [self appendText:sender];
  399.  
  400.     sprintf(buffer,"\nU.S. Equities Analysis Report\n\n");
  401.     [self appendText:sender];
  402.  
  403.     // Buy Report
  404.  
  405.         sprintf(buffer,"** Buy **\n\n");
  406.         [self appendText:sender];
  407.  
  408.     sprintf(buffer,"Stock Price: %.2f\n", [StockPrice floatValue]);
  409.     [self appendText:sender];
  410.  
  411.     sprintf(buffer,"Number of Shares: %.0f\n", [NumberOfShares floatValue]);
  412.     [self appendText:sender];
  413.  
  414.     sprintf(buffer,"Value: %.2f\n", [TotalStockPrice floatValue]);
  415.     [self appendText:sender];
  416.  
  417.     sprintf(buffer,"Commission: %.2f\n", [TotalCommission floatValue]);
  418.     [self appendText:sender];
  419.  
  420.     sprintf(buffer,"Net Amount: %.2f\n", [Total floatValue]);
  421.     [self appendText:sender];
  422.  
  423.     sprintf(buffer,"Net Amount per Share: $%.2f\n\n", [TotalCommPerShare floatValue]);
  424.     [self appendText:sender];
  425.  
  426.  
  427.     // Sell Report
  428.  
  429.         sprintf(buffer,"** Sell **\n\n");
  430.         [self appendText:sender];
  431.  
  432.     sprintf(buffer,"Stock Price: %.2f\n", [StockPrice2 floatValue]);
  433.     [self appendText:sender];
  434.  
  435.     sprintf(buffer,"Number of Shares: %.2f\n", [NumberOfShares2 floatValue]);
  436.     [self appendText:sender];
  437.  
  438.     sprintf(buffer,"Value: %.2f\n", [TotalStockPrice2 floatValue]);
  439.     [self appendText:sender];
  440.  
  441.     sprintf(buffer,"Commission: %.2f\n", [TotalCommission2 floatValue]);
  442.     [self appendText:sender];
  443.  
  444.     sprintf(buffer,"Net Amount: %.2f\n", [Total2 floatValue]);
  445.     [self appendText:sender];
  446.  
  447.     sprintf(buffer,"Net Amount per Share: %.2f\n\n", [NetAmountPerShare2 floatValue]);
  448.     [self appendText:sender];
  449.     
  450.  
  451.     // Analysis Report
  452.  
  453.         sprintf(buffer,"** Analysis **\n\n");
  454.         [self appendText:sender];
  455.  
  456.     sprintf(buffer,"Share Price Difference: %.2f\n", [SharePriceDifference floatValue]);
  457.     [self appendText:sender];
  458.  
  459.     sprintf(buffer,"Total Commission Charges: %.2f\n", [TotalCommissionCharges floatValue]);
  460.     [self appendText:sender];
  461.  
  462.     sprintf(buffer,"Total Commission Charges per share: %.5f\n", [TotalCommPerShare floatValue]);
  463.     [self appendText:sender];
  464.  
  465.     sprintf(buffer,"Net Profit or lost per Share: %.5f\n", [NetProfitLostPerShare floatValue]);
  466.     [self appendText:sender];
  467.  
  468.     sprintf(buffer,"Net Profit or lost: %.2f\n", [NetProfitLost floatValue]);
  469.     [self appendText:sender];
  470.  
  471.     sprintf(buffer,"*Breakeven* Price per Share: %.2f\n", [BreakEven floatValue]);
  472.     [self appendText:sender];
  473.  
  474.     return self;
  475. }
  476.  
  477. // APPENDTEXT
  478. - appendText:sender
  479. // This method appends a string called buffer to the end 
  480. // of AmortDisplay scrollView
  481. {
  482.         int HowLongIsTheText;
  483.     
  484.     document = [MyScrollView docView];
  485.         
  486.     // Determines how many characters are in the 
  487.         // AmortDisplay scrollView document
  488.     HowLongIsTheText = [document textLength]; 
  489.         
  490.         // Selects and empty selection, which in fact places
  491.         // the cursor at the end of the document.
  492.     [document setSel:HowLongIsTheText:HowLongIsTheText];
  493.         
  494.     // Replaces the selection (in this case it is empty) 
  495.         // with buffer text string.
  496.     [document replaceSel:buffer]; 
  497.  
  498.     return self; //normal return
  499. }
  500.  
  501.  
  502. - PrintCalc:sender
  503. {
  504.  
  505.     [[MyScrollView docView] printPSCode:self];
  506.  
  507.     return self;
  508. }
  509.  
  510. - PrintBuy:sender
  511. {
  512.  
  513.     [BuyBox printPSCode:self];
  514.  
  515.     return self;
  516. }
  517.  
  518. - PrintSell:sender
  519. {
  520.  
  521.     [SellBox printPSCode:self];
  522.  
  523.     return self;
  524. }
  525.  
  526. - TeleMax:sender
  527. {
  528.     return self;
  529. }
  530.  
  531.  
  532. @end
  533.